#include <iostream>
#include <vector>
#include <string>

using namespace std;

string addBinary(string a, string b) {
    int carry = 0, len = max(a.size(), b.size()); string ret;
    for(int i = 0; i < len; i++){
        // int ai = int(a.size())-i, bi = int(b.size())-i;
        // 经典错误：string.size() 的返回值类型是 size_t 不是 int，无符号数和有符号数进行运算的时候有符号数会被提升到无符号数
        char at = (int(a.size())-i > 0 ? a[a.size()-1-i] : '0'), bt = (int(b.size())-i > 0 ? b[b.size()-1-i] : '0'),
             t = at + bt - '0' + carry;
        if(t > '1'){
            ret.insert(ret.begin(), t-2);
            carry = 1;
        }else{
            ret.insert(ret.begin(), t);
            carry = 0;
        }
    }
    return carry == 1 ? "1" + ret : ret;
}

int main(){
    string a = "1010", b = "1011";
    cout << addBinary(a, b) << endl;
    return 0;
}
